
dojo.provide("slipstream.data.JRSBuilder");
dojo.declare("slipstream.data.JRSBuilder", null, {
	lang: 'sv',
    source: '/api/interface.json',
	/*constructor: function(){},*/
    constructor: function(){
		this.generate();
	},
	generate: function(lang){
		lang=(lang?lang:'sv');
        var xhrArgs = {
            url: this.source,
            handleAs: "json",
			preventCache: true,
            load: dojo.hitch(this,function(data){
				//storeData=data;
				//console.log('test');
				dojo.forEach(data,function(item,index){
					//var buildstring=item.name+'Store='+item.settings.engine+'(item.arguments);';
					this.getInstance(item,lang)
					/*var buildstring=item.name+'Store=new '+item.settings.engine+'(item.arguments);';
					//console.log(buildstring);
					temp=eval(buildstring);
					temp.lang=lang;*/
					//console.log(temp);
				});
				preloadStores();
            }),
            error: function(error){
				console.log(error);
                //targetNode.innerHTML = "An unexpected error occurred: " + error;
            }
        }
        
        //Call the asynchronous xhrGet
        this.request = dojo.xhrGet(xhrArgs);
    },
	
	getInstance: function(item,lang){
		var buildstring=item.name+'Store=new '+item.settings.engine+'(item.arguments);';
		//console.log(buildstring);
		temp=eval(buildstring);
		temp.lang=lang;
	}
});
